home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-15 | 1.8 KB | 79 lines | [TEXT/MPS ] |
- (*
- TCPState(connectionID) -- Return the state of the TCP connection.
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- pascal -w TCPState.p
- link -m ENTRYPOINT -o HyperCommands -rt XFCN=7867 -sn Main=TCPState ∂
- TCPState.p.o "{Libraries}HyperXLib.o" "{MPW}"Libraries:interface.o
-
- © Copyright 1988 by Apple Computer, Inc.
-
- Initial coding 12/88 by Harry R. Chesley.
- *)
-
- {$R-}
-
- {$S TCPState } { Segment name must be the same as the command name. }
-
- unit DummyUnit;
-
- interface
-
- uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- implementation
-
- procedure TCPState(paramPtr: XCmdPtr); forward;
-
- procedure EntryPoint(paramPtr: XCmdPtr);
-
- begin
- TCPState(paramPtr);
- end;
-
- procedure TCPState(paramPtr: XCmdPtr);
-
- var state: Str255;
-
- procedure Fail(errMsg: Str255); { set theResult and quit }
- begin
- paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
- exit(TCPState);
- end;
-
- {$I TCPUtil.inc}
-
- begin
- if paramPtr^.paramCount <> 1 then Fail('§§§ parameter count is not 1 §§§');
-
- SetUpConnectionID;
-
- { Check for an open still in progress (note that this control block, particularly the ioResult
- field was copied from the async control block by SetUpConnectionID. }
- if SyncControlBlock.ioResult > 0 then state := 'waiting for open'
- else
- begin
- { Read status. }
- ZeroIOParms;
- SyncControlBlock.csCode := TCPcsStatus;
- if PBControl(@SyncControlBlock,false) <> noErr then state := 'closed'
- else
- { Decode status into text. }
- case ControlByteAtOffset(52) of
- 0: state := 'closed';
- 2: state := 'listening';
- 4,6: state := 'opening';
- 8: state := 'established';
- 10,12,16,18,20: state := 'closing';
- 14: state := 'please close';
- otherwise state := 'unknown state';
- end;
- end;
- paramPtr^.returnValue := PasToZero(paramPtr,state);
- end;
-
- end.
-